<?php
session_start();
if (isset($_SESSION["username"])) {
?>
  <?php require_once('common/header.php'); ?>
  <!--页面主要内容-->
<main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <ul class="nav nav-tabs page-tabs">
                <li > <a href="other.php">同源系统</a> </li>
                <li class="active"> <a href="gantan.php">敢探号配置</a> </li>
                <li > <a href="haoke.php">号氪云配置</a> </li>
              </ul>
       <?php
      include_once("../untils/conn.php");
        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
        $domain = $_SERVER['HTTP_HOST'];
        $url = $protocol . $domain;
        $groups = 'gantanhao';
        $sql = "SELECT * FROM config_api WHERE groups = '$groups'";
        $result = mysqli_query($con, $sql);
        
        // 检查查询结果是否为空
        if (mysqli_num_rows($result) > 0) {
            // 获取第一行数据
            $row = mysqli_fetch_assoc($result);
            $userid = $row['userid'];
            $token = $row['token'];
        } else {
           
        }
        
      ?>
      <div class="">
        <div class="card-body">
          <form class="form-horizontal" action="controller/doApiConfig.php" method="POST">
            <div class="form-group">
              <label for="title" class="col-xs-12">感探号share_id：</label>
              <div class="col-xs-12">
                <input type="text" class="form-control" name="userid" placeholder="号卡氪云id" value="<?php echo $userid ?>" required>
              </div>
            </div>
            <div class="form-group">
              <label for="title" class="col-xs-12">感探号token：</label>
              <div class="col-xs-12">
                <input type="text" class="form-control" name="token" placeholder="号氪云Token" value="<?php echo $token ?>" >
              </div>
            </div>
            <div class="form-group">
              <label for="title" class="col-xs-12">敢探号回调地址：</label>
              <div class="col-xs-12">
                <input class="form-control" type="text" value="<?php echo $url ?>/api/open/callback.php?type=gantanhao" readonly>
              </div>
            </div>
            
            <div class="form-group">
              <input type="hidden" name="type" value="<?php echo $groups ?>">
              <div class="offset-2 col-xs-12">
                <button class="btn btn-success" type="submit" value="添加">确认修改</button>
                <!-- <button class="btn btn-danger ml-3" type="reset" value="重置">返回</button> -->
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </main>
  <!--End 页面主要内容-->
  <?php require_once('common/footer.php'); ?>
<?php
} else {
  echo "<script>alert('您尚未登录，没有权限访问该页面');location.href='login.php';</script>";
}
